package com.sakura.content.api;

import com.sakura.base.common.handler.ValidationGroups;
import com.sakura.base.common.model.PageParams;
import com.sakura.base.common.model.PageResult;
import com.sakura.content.service.ElderlyService;
import com.sakura.elderly.dto.ElderlyQueryParamDto;
import com.sakura.model.entity.Elderly;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author : Sakura
 * @Date : 2024/1/26 14:41
 * @Description : TODO 用来接收...的请求
 */
@Api(value = "/api/elderly", tags = {"老人表"})
@RestController
@RequestMapping("/api/elderly")
//解决跨域问题
@CrossOrigin
public class ElderlyController {

    @Autowired
    private ElderlyService elderlyService;

    /**
     * 分页查询
     *
     * @param :
     * @return PageResult
     * @author Sakura
     * @date 2024/1/26 14:42
     */
    @ApiOperation("老人分页查询")
    @PostMapping("/list")
    public PageResult list(PageParams pageParams,@RequestBody @Validated(ValidationGroups.Insert.class) ElderlyQueryParamDto queryParamDto) {

        PageResult<Elderly> elderlyPageResult = elderlyService.queryElderlyBaseList(pageParams, queryParamDto);
        return elderlyPageResult;
    }
}
